import 'package:flutter/material.dart';

void main() {
  runApp(MainPage());
}
class MainPage extends StatefulWidget {
  MainPage({Key? key}) : super(key: key);

  @override
  _MainPageState createState() => _MainPageState();
}

class _MainPageState extends State<MainPage> {
  final ScrollController _controller = ScrollController();//滚动控制器
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
       home:Scaffold(appBar:AppBar(title:Text("滚动列表"),) ,
       body:ListView.separated( 
          itemBuilder: (BuildContext context,int index){
          return Container(
            // margin: EdgeInsets.only(bottom: 20),
            width:double.infinity,
            height:100,
            color: Colors.blue,
            child:Text("第${index+1}个",
            style:TextStyle(
              fontSize: 20,
              color: Colors.white,
            )),
            alignment: Alignment.center,
          );
        }, separatorBuilder: (BuildContext context,int index){
          return Container(
            height: 10,
            width: double.infinity,
            color: Colors.red,
          );
        }, itemCount: 100)
      //  body:ListView.builder(
      //   itemCount: 100,
      //   itemBuilder: (BuildContext context,int index){
      //     return Container(
      //       margin: EdgeInsets.only(bottom: 20),
      //       width:double.infinity,
      //       height:100,
      //       color: Colors.blue,
      //       child:Text("第${index+1}个",
      //       style:TextStyle(
      //         fontSize: 20,
      //         color: Colors.white,
      //       )),
      //       alignment: Alignment.center,
      //     );
      //   },
      //   padding: EdgeInsets.all(20),
      //  )
    ));  
  }
}